﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Organization.aspx.cs" Inherits="Web.SearchPopUp.Organization" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link rel="stylesheet" type="text/css" href="../CSS/style.css" />
    <link rel="stylesheet" type="text/css" href="../CSS/bootstrap.min.css" />
    <link href="../CSS/Fonts.css" rel='stylesheet' type='text/css' />
    <script src="../JS/jquery.min.js"></script>
    <script src="../JS/bootstrap.min.js"></script>
    <style type="text/css">
        .RadGrid .rgHoveredRow {
            cursor: pointer !important;
        }
    </style>
    <telerik:RadCodeBlock ID="RadCodeBlock" runat="server">
        <script type="text/javascript">
            function GetRadWindow() {
                var oWindow = null;
                if (window.radWindow) oWindow = window.radWindow;
                else if (window.frameElement.radWindow) oWindow = window.frameElement.radWindow;
                return oWindow;
            }
            function pageLoad(sender, eventArgs) {
                if (!eventArgs.get_isPartialLoad()) {
                    $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("InitialPageLoad");
                }
            }
            var arrOb = new Array();
            function RowSelected(sender, eventArgs) {
                var grid = sender;
                var MasterTable = grid.get_masterTableView();
                var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
                var cell = MasterTable.getCellByColumnUniqueName(row, "ORGANIZATION_NAME");

                var oArg = new Object();
                oArg.SearchType = "Organization";
                oArg.OrgName = cell.innerHTML;
                oArg.OrgID = eventArgs.getDataKeyValue("ID");

                if (oArg.OrgName && oArg.OrgID) {
                    var checkexist = false;
                    for (var i = 0 ; i < arrOb.length; i++) {
                        if (oArg.OrgID == arrOb[i].OrgID) {
                            checkexist = true;
                            break;
                        }
                    }
                    if (checkexist == false)
                        arrOb.push(oArg);
                }
            }
            function RowDeselecting(sender, eventArgs) {
                var orgID = eventArgs.getDataKeyValue("ID");

                var index = -1;
                for (var i = 0 ; i < arrOb.length; i++) {
                    if (orgID == arrOb[i].OrgID) {
                        index = i;
                        break;
                    }
                }
                if (index != -1) {
                    arrOb.splice(index, 1);
                }
            }
            function OkClick() {
                var oArg = new Object();
                oArg.SearchType = "Organization";
                oArg.OrgName = oArg.OrgID = "";
                for (var i = 0 ; i < arrOb.length; i++) {
                    oArg.OrgName = oArg.OrgName + arrOb[i].OrgName + ";";
                    oArg.OrgID = oArg.OrgID + arrOb[i].OrgID + ";";
                }
                if (oArg.OrgID != "") {
                    oArg.OrgID = oArg.OrgID.slice(0, oArg.OrgID.length - 1);
                    oArg.OrgName = oArg.OrgName.slice(0, oArg.OrgName.length - 1);
                }
                var oWnd = GetRadWindow();
                oWnd.close(oArg);
            }

            function onClose() {
                window.close();
            }
            var rowIndex = -1;
            function chbOnClicked(i) {
                rowIndex = i;
            }
            function chbHeader_Checked(sender, args) {
                var grid = $find("<%= RadGrid1.ClientID %>");
                var masterTableView = grid.get_masterTableView();
                var rows = masterTableView.get_dataItems();
                for (var i = 0; i < rows.length; i++) {
                    var chbItem = rows[i].findControl("chbItem");
                    chbItem.set_checked(sender.get_checked());
                    rows[i].set_selected(sender.get_checked());
                }
            }
            function chbItem_Checked(sender, args) {
                if (rowIndex != -1) {
                    var grid = $find("<%= RadGrid1.ClientID %>");
                    var masterTableView = grid.get_masterTableView();
                    var row = masterTableView.get_dataItems()[rowIndex];
                    row.set_selected(sender.get_checked());
                }
            }
        </script>
    </telerik:RadCodeBlock>
</head>
<body class="popup-body">
    <form id="form1" runat="server">
        <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel2" runat="server" IsSticky="true" CssClass="MyModalPanel" Transparency="50" />
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
            <AjaxSettings>
                <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="mainPanel" LoadingPanelID="RadAjaxLoadingPanel2" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
                <telerik:AjaxSetting AjaxControlID="mainPanel">
                    <UpdatedControls>
                        <telerik:AjaxUpdatedControl ControlID="mainPanel" LoadingPanelID="RadAjaxLoadingPanel2" />
                    </UpdatedControls>
                </telerik:AjaxSetting>
            </AjaxSettings>
        </telerik:RadAjaxManager>
        <div id="Div1">
            <asp:Panel ID="mainPanel" runat="server">
                <asp:Panel ID="Panel1" runat="server" Style="display: none">
                    <div class="container-fluid">
                        <div class="row">
                            <div class="edit-form highlight" style="margin: 0">
                                <div class="control-group">
                                    <h4>Company Search</h4>
                                </div>
                                <div class="control-group popup-form">
                                    <div class="col-md-4 distance-control">
                                        <div class="col-md-4">
                                            <label class="control-label">Company Name </label>
                                        </div>
                                        <div class="col-md-8">
                                            <div class="controls">
                                                <asp:TextBox ID="txtCompanyName" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-4 distance-control">
                                        <div class="col-md-4">
                                            <label class="control-label">Contact Number </label>
                                        </div>
                                        <div class="col-md-8">
                                            <div class="controls">
                                                <asp:TextBox ID="txtContactNumber" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-4 distance-control">
                                        <div class="col-md-4">
                                            <label class="control-label">Email </label>
                                        </div>
                                        <div class="col-md-8">
                                            <div class="controls">
                                                <asp:TextBox ID="txtPrimaryEmail" runat="server" class="form-control" onkeypress="isPressEnter(event)" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                                <div class="control-group popup-form">
                                    <div class="col-md-4 distance-control">
                                        <div class="col-md-4">
                                            <label class="control-label">Date Created From </label>
                                        </div>
                                        <div class="col-md-8">
                                            <div class="controls">
                                                <telerik:RadDatePicker ID="dpDateCreatedFrom" runat="server" Width="50%">
                                                    <DateInput ReadOnly="true" ID="RadDateInput1" runat="server">
                                                    </DateInput>
                                                    <Calendar ReadOnly="true" ID="Calendar1" runat="server" UseColumnHeadersAsSelectors="False"
                                                        UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                        <SpecialDays>
                                                            <telerik:RadCalendarDay Repeatable="Today" ItemStyle-CssClass="rcToday">
                                                            </telerik:RadCalendarDay>
                                                        </SpecialDays>
                                                    </Calendar>
                                                </telerik:RadDatePicker>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-4 distance-control">
                                        <div class="col-md-4">
                                            <label class="control-label">Date Created To </label>
                                        </div>
                                        <div class="col-md-8">
                                            <div class="controls">
                                                <telerik:RadDatePicker ID="dpDateCreatedTo" runat="server" Width="50%">
                                                    <DateInput ReadOnly="true" ID="DateInput2" runat="server">
                                                    </DateInput>
                                                    <Calendar ReadOnly="true" ID="Calendar2" runat="server" UseColumnHeadersAsSelectors="False"
                                                        UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                        <SpecialDays>
                                                            <telerik:RadCalendarDay Repeatable="Today" ItemStyle-CssClass="rcToday">
                                                            </telerik:RadCalendarDay>
                                                        </SpecialDays>
                                                    </Calendar>
                                                </telerik:RadDatePicker>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="col-md-4 distance-control" id="divAssignTo" runat="server">
                                        <div class="col-md-4">
                                            <label class="control-label">Assign To </label>
                                        </div>
                                        <div class="col-md-8">
                                            <div class="controls">
                                                <telerik:RadComboBox ID="ddlAssignedTo" runat="server" class="form-control"
                                                    Width="80%" Filter="StartsWith" MaxHeight="700px" />
                                            </div>
                                        </div>
                                    </div>
                                    <div class="clearfix"></div>
                                </div>
                            </div>
                        </div>
                        <div class="row popup-btn">
                            <div class="col-md-12 btn-edit">
                                 <asp:LinkButton ID="btnOK" runat="server" OnClientClick="OkClick()" class="btn btn-defaul" style="float: left; margin-left:-10px;" >
                                    <img src="../Images/done.png" style="width: 20px; height: 20px;" />
                                    OK
                                </asp:LinkButton>
                                <asp:LinkButton ID="btnSearch" runat="server" OnClick="btnSearch_ServerClick" class="btn btn-defaul">
                                    <img src="../Images/search.png" style="width: 20px; height: 20px" />
                                    Search
                                </asp:LinkButton>
                                <button id="Button2" type="button" class="btn btn-defaul" onclick="onClose()">
                                    <img src="../Images/delete.png" style="width: 20px; height: 20px" />
                                    Cancel
                                </button>
                            </div>
                        </div>
                        <div class="row">
                            <div class="edit-form highlight">
                                <div class="control-group">
                                    <h4>Companies</h4>
                                </div>
                                <div style="width: 100%">
                                    <telerik:RadGrid ID="RadGrid1" ShowStatusBar="True" runat="server" AllowPaging="True" AllowSorting="True" AllowMultiRowSelection="false" 
                                        AutoGenerateColumns="false" GridLines="None" Width="100%" OnNeedDataSource="RadGrid1_NeedDataSource" OnPreRender="RadGrid1_PreRender">
                                        <ClientSettings EnableRowHoverStyle="false">
                                            <Selecting AllowRowSelect="True" />
                                            <ClientEvents OnRowSelected="RowSelected" OnRowDeselecting="RowDeselecting" />
                                        </ClientSettings>
                                        <MasterTableView PageSize="10" NoDetailRecordsText="No records" NoMasterRecordsText="No records" ShowHeader="true" ClientDataKeyNames="ID" TableLayout="Fixed">
                                            <Columns>
                                                <telerik:GridClientSelectColumn UniqueName="ClientSelectColumn">
                                                </telerik:GridClientSelectColumn>

                                                <%--<telerik:GridTemplateColumn>
                                                    <HeaderTemplate>
                                                        <telerik:RadButton ID="chbHeader" runat="server" ToggleType="CheckBox" ButtonType="ToggleButton" OnClientCheckedChanged="chbHeader_Checked"
                                                            AutoPostBack="false" CausesValidation="false" />
                                                    </HeaderTemplate>
                                                    <ItemTemplate>
                                                        <telerik:RadButton ID="chbItem" runat="server" ToggleType="CheckBox" ButtonType="ToggleButton" OnClientCheckedChanged="chbItem_Checked"
                                                            AutoPostBack="false" CausesValidation="false" />
                                                    </ItemTemplate>
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="5%" />
                                                    <ItemStyle HorizontalAlign="center" Width="5%" />
                                                </telerik:GridTemplateColumn>--%>
                                                <telerik:GridBoundColumn DataField="ORGANIZATION_NAME" HeaderText="Company Name" UniqueName="ORGANIZATION_NAME" SortExpression="ORGANIZATION_NAME">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="18%" />
                                                     <ItemStyle Wrap="false" HorizontalAlign="center" Width="20%" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="COMPANY_WEBSITE" HeaderText="Company Website" UniqueName="COMPANY_WEBSITE" SortExpression="COMPANY_WEBSITE">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="20%" />
                                                     <ItemStyle Wrap="false" HorizontalAlign="center" Width="20%" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="CONTACT_NUMBER" HeaderText="Contact Number" UniqueName="CONTACT_NUMBER" SortExpression="CONTACT_NUMBER">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                                     <ItemStyle Wrap="false" HorizontalAlign="center" Width="10%" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="PRIMARY_EMAIL" HeaderText="Primary Email" UniqueName="PRIMARY_EMAIL" SortExpression="PRIMARY_EMAIL">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="18%" />
                                                     <ItemStyle Wrap="false" HorizontalAlign="center" Width="20%" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="OFFICE_CITY" HeaderText="Office City" UniqueName="OFFICE_CITY" SortExpression="OFFICE_CITY">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                                     <ItemStyle Wrap="false" HorizontalAlign="center" Width="10%" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="OFFICE_COUNTRY" HeaderText="Office Country" UniqueName="OFFICE_COUNTRY" SortExpression="OFFICE_COUNTRY">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                                     <ItemStyle Wrap="false" HorizontalAlign="center" Width="10%" />
                                                </telerik:GridBoundColumn>
                                                <telerik:GridBoundColumn DataField="ASSIGN_TO" HeaderText="Assigned To" UniqueName="ASSIGN_TO" SortExpression="ASSIGN_TO">
                                                    <HeaderStyle Font-Bold="true" HorizontalAlign="center" Width="10%" />
                                                     <ItemStyle Wrap="false" HorizontalAlign="center" Width="10%" />
                                                </telerik:GridBoundColumn>
                                            </Columns>
                                            <PagerStyle HorizontalAlign="Right" Mode="NextPrevNumericAndAdvanced" PagerTextFormat="Page: {4} &amp;nbsp;|&amp;nbsp; Current Page: {0} / {1}, Items: {2} - {3} / {5}." AlwaysVisible="True" />
                                        </MasterTableView>
                                        <PagerStyle Mode="NumericPages"></PagerStyle>
                                    </telerik:RadGrid>
                                </div>
                            </div>
                            <div class="clearfix"></div>
                            
                        </div>
                    </div>
                </asp:Panel>
            </asp:Panel>
        </div>
    </form>
</body>
</html>
